package main

import (
	"fmt"
	"sync"
)

var once sync.Once

type syncOnceSingle struct {
}

var syncOnceSingleInstance *syncOnceSingle

func getSyncOnceSingleInstance() *syncOnceSingle {
	if syncOnceSingleInstance == nil {
		once.Do(
			func() {
				fmt.Println("Creating syncOnceSingle instance now.")
				syncOnceSingleInstance = &syncOnceSingle{}
			})
	} else {
		fmt.Println("syncOnceSingle instance already created.")
	}

	return syncOnceSingleInstance
}
